<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Document</title>
    <style>
        .container{
            width: 800px;
            border: 1px solid #333;

            position: relative;
        }

        .d1,.d2,.d3,.d4{
            width: 100px;
            height: 100px;
        }
        .d1{
            background: red;

            /* 相对定位 */
            position: relative;
            top: 30px;
            left: 150px;
        }
        .d2{
            background: blue;

            /* 绝对定位 */
            position: absolute;
            bottom: 20px;
            right: 20px;
        }
        .d3{
            background: green;

            /* 固定定位 */
            position: fixed;
            top: 50px;
            right: 100px;
        }
        .d4{
            background: yellow;
        }
    </style>
</head>
<body>
    <div class="container">
        <div class="d1">div1</div>
        <div class="d2">div2</div>
        <div class="d3">div3</div>
        <div class="d4">div4</div>
    </div>
</body>
</html>